#pragma once
#ifdef USE_MITM
#include "IBBS2chProxySocket.h"
#ifdef USE_GNUTLS
#include <gnutls/gnutls.h>
#elif defined(USE_WOLFSSL)
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>
#elif defined(USE_MBEDTLS)
#include <mbedtls/ssl.h>
#include <mbedtls/net_sockets.h>
#include <mbedtls/x509_crt.h>
#else
#include <openssl/ssl.h>
#endif

class BBS2chProxySecureSocket : public IBBS2chProxySocket {
public:
	BBS2chProxySecureSocket(int sock, const char *host);
	~BBS2chProxySecureSocket();
	static int initializeCerts(const char *certPath, const char *keyPath);
	static void generateAndPrintSelfSignedCertificate(void);
	virtual int read(char *buffer, int length);
	virtual int readLine(char *buffer, int maxLength);
	virtual int write(const char *buffer, int length);
	virtual int writeString(const std::string &str);
	virtual void close(void);
private:
	int socket;
#ifdef USE_GNUTLS
	gnutls_session_t session;
	gnutls_certificate_credentials_t x509_cred;
#elif defined(USE_WOLFSSL)
	WOLFSSL_CTX *ctx;
	WOLFSSL *ssl;
#elif defined(USE_MBEDTLS)
	mbedtls_ssl_context ssl;
	mbedtls_ssl_config conf;
	mbedtls_net_context client;
	mbedtls_x509_crt server_cert;
#else
	SSL_CTX *ctx;
	SSL *ssl;
#endif
};
#endif
